package test;

import java.util.Iterator;
import java.util.List;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

public class DWObject {
	private String node;
	private String value;
	private Map <String, String> attributes = new HashMap<String, String>();
	private Map <String, String> prefixes = new HashMap<String, String>();
	private List<DWObject> childNodes = new ArrayList<DWObject>();

	public DWObject (String pNode) {
		//node = pNode;
		this(pNode,null);
	}
	public DWObject (String pNode, String pValue) {
		node = pNode;
		value = pValue;
	}

	
	public void setAttribute (String attrib, String value) {
		attributes.put(attrib, value);
	}
	public void setPrefix (String attrib, String prefix) {
		prefixes.put(attrib, prefix);
	}

	public Map<String, String> getAttributes () {
		return attributes;
	}
	
	public String getPrefix (String attrib) {
		return (prefixes.containsKey(attrib))
				? prefixes.get(attrib)
				: ""		;
	}
	
	public DWObject addChildObject(String pNode) {
		return addChildObject(pNode,null);
	}
	public DWObject addChildObject(String pNode, String pValue) {
		DWObject nDWO = new DWObject(pNode, pValue);
		childNodes.add(nDWO);
		return nDWO;
	}
	
	public Iterator<DWObject> getChildrenIterator() {
		return childNodes.iterator();
	}

	public String getNodeName(){
		return node;
	}
	public String getNodeValue(){
		return value;
	}

}
